package com.pp.common.bean;

import com.pp.common.constant.enums.CoreMsg;

import static com.pp.common.bean.ResultObject.*;

public class ResultBuilder<T> {

    public static <T> ResultObject<T> success(T t) {
        return new ResultObject<T>(SUCCESS_CODE, SUCCESS_MSG, t);
    }

    public static <T> ResultObject<T> error(String code, String msg) {
        return new ResultObject<T>().setCode(code).setMsg(msg);
    }

    public static <T> ResultObject<T> error(CoreMsg coreMsg) {
        return new ResultObject<T>().setCode(coreMsg.getCode()).setMsg(coreMsg.getMsg());
    }

}
